<template>
  <div>
    <Header :left="true" leftText="返回" title="修改关闭加严申请" />

    <!-- 滑动区域，适应手机分辨率 -->
    <div class="textScroll">
      <div class="divMessage">
        <Field
          v-model="item.AddStrictID"
          size="small"
          class="Field"
          center
          colon
          label="加严管控记录ID"
          placeholder="选择加严管控记录ID"
          label-width="110px"
        />
        <Field
          v-model="item.StrictDescription"
          :readonly="true"
          name="加严管控描述"
          label="加严管控描述"
          placeholder="自动带出"
          rows="2"
          autosize
          type="textarea"
          maxlength="100"
          show-word-limit
          label-width="110px"
        />
        <van-button
          v-if="this.status == false"
          color="#138087"
          @click.stop="confirmmessage(item)"
          style="
            width: 85px;
            height: 40px;
            font-size: 12px;
            position: absolute;
            left: 80%;
          "
          type="primary"
          text="修改"
        />
      </div>
      <!-- 基本信息 -->
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">基本信息</van-col>
      </van-row>
      <div class="divMessage">
        <Field
          v-model="item.FactoryID"
          size="small"
          class="Field"
          center
          colon
          label="工厂代码"
          placeholder="自动带出"
          label-width="110px"
          :readonly="true"
        />

        <Field
          v-model="item.RequestMan"
          size="small"
          class="Field"
          center
          colon
          label="申请人"
          placeholder="请输入申请人"
          label-width="110px"
        />
        <Field
          v-model="item.ReqDescription"
          size="small"
          class="Field"
          center
          colon
          label="申请描述"
          placeholder="请输入申请描述"
          label-width="110px"
        />
        <Field
          v-model="item.RequestReason"
          size="small"
          class="Field"
          center
          colon
          label="申请质量理由"
          placeholder="请输入申请质量理由"
          label-width="110px"
        />
      </div>
      <!-- 主管审核 -->
      <!-- <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">主管审核</van-col>
      </van-row>
      <div class="divMessage">
        <Field
          v-model="item.Checked"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="是否已审核"
          label-width="110px"
        />
        <Field
          v-model="item.Passed"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="是否通过"
          label-width="110px"
        />
        <Field
          v-model="item.CheckedMan"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="审核人"
          label-width="110px"
        />
        <Field
          v-model="item.CheckedDatetime"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="审核时间"
          label-width="110px"
        />

        <Field
          v-model="item.CkeckedMemo"
          :readonly="true"
          name="处置建议"
          label="处置建议"
          placeholder="审核备注"
          rows="2"
          autosize
          type="textarea"
          maxlength="100"
          show-word-limit
          label-width="110px"
        />
      </div> -->
      <!-- 操作历史 -->
      <!-- <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">操作历史</van-col>
      </van-row> -->
      <!-- <div class="divMessage">
        <Field
          v-model="item.Creator"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="创建者"
          label-width="110px"
        />
        <Field
          v-model="item.CreateDatetime"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="创建日期时间"
          label-width="110px"
        />
        <Field
          v-model="item.Modifytor"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="修改者"
          label-width="110px"
        />
        <Field
          v-model="item.ModifyDatetime"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="最后修改日期"
          label-width="110px"
        />
        <Field
          v-model="item.Id"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="申请单ID"
          label-width="110px"
        />
      </div> -->
      <div style="margin: 16px" v-if="this.status == false">
        <van-button
          color="#138087"
          round
          block
          type="info"
          native-type="submit"
          @click="selectDetails(item)"
          >查看加严管控详情</van-button
        >
      </div>
      <div style="margin: 16px" v-if="this.status == false">
        <van-button
          color="#138087"
          round
          block
          type="info"
          native-type="submit"
          @click="submitCheck()"
          >确认提交</van-button
        >
      </div>
    </div>
  </div>
</template>
<script>
import {
  Icon,
  NoticeBar,
  Button,
  Row,
  Tag,
  Checkbox,
  Pagination,
  popup,
  Loading,
  Popup,
  Panel,
  ImagePreview,
  Toast,
  tab,
  tabs,
  Divider,
  Image as VanImage,
  Field,
  CellGroup,
  Cell,
  Picker,
  Uploader,
  Dialog,
  Col,
  RadioGroup,
  Radio,
} from "vant";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { _httpClient } from "@/libs/apisie";
import { storage } from "@/libs/utils";
import {
  removeToken,
  getToken,
  setBaseApiFrefix,
  getBaseApiFrefix,
} from "@/libs/auth";
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(tab);
Vue.use(tabs);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Icon);
Vue.use(VanImage);
Vue.use(Divider);
Vue.use(Checkbox);
Vue.use(Pagination);
Vue.use(Panel);
Vue.use(Dialog);
Vue.use(Picker);
Vue.use(popup);
Vue.use(Uploader);
Vue.use(Loading);
Vue.use(Field);
Vue.use(RadioGroup);
Vue.use(Radio);
import Header from "@/components/header.vue";
import apicloud from "@/libs/apicloud";
export default {
  name: "heyu4",

  components: {
    Button,
    NoticeBar,
    Header,
    ImagePreview,
    Icon,
    Row,
    tab,
    popup,
    Popup,
    tabs,
    Tag,
    VanImage,
    Toast,
    Divider,
    Field,
    CellGroup,
    Cell,
    Uploader,
    Picker,
    Dialog,
    Col,
    RadioGroup,
    Radio,
  },

  data() {
    return {
      btnLoading: false,
      winName: "", //窗口名
      user: [], //当前登录用户
      form: {},
      faultTypes: [],
      stopReson: [],
      uploadSuccess: false,
      columnsDealType: [],
      columnsEmployee: [],
      columnsQProblem: [],
      columnsshift: [],
      showPickerEmployee: false,
      showPickerQProblem: false,
      item: {},
      valuepDealTypeName: "",
      EmployeeName: "",
      time: "",
      FactoryID: "",
      valuepShiftName: "",
      CheckTypeName: "",
      QProblemName: "",
      valueteamid: "",
      nowDate: "",
      EmployeeID: "",
      result: [],
      //领班
      QCLeaderAgreeValue: "",
      //带版主管
      TeamLeaderAgreeValue: "",
      //质量负责人
      QCManagerAgreeValue: "",
      //生产部门负责人
      PrdManagerAgreeValue: "",
      //利润点负责人
      FactoryManagerAgreeValue: "",
      //当前状态
      status: "",
      //是否显示人员
      showEmployee: false,
    };
  },
  created: function () {
    this.user = JSON.parse(storage.get("user"));
    let oldHight = api.winWidth;
    this.screenWidth = oldHight;
    this.item = api.pageParam.item;
    this.form = api.pageParam.form;
    this.status = this.item.Checked;
    this.nowDate = this.getNowTime();
  },

  mounted: function () {
    if (typeof this.form.Id != "undefined") {
      this.item.AddStrictID = this.form.Id;
    }
    if (typeof this.form.FactoryID != "undefined") {
      this.item.FactoryID = this.form.FactoryID;
    }
    if (typeof this.form.StrictDescription != "undefined") {
      this.item.StrictDescription = this.form.StrictDescription;
    }
  },
  methods: {
    getNowTime() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      return dateTime;
    },
    //确认
    async confirmmessage(item) {
      api.openWin({
        name: "heyu5",
        url: "./employee-heyu5.html",
        reload: true,
        pageParam: {
          item: item,
          form: {},
        },
      });
    },
    async selectDetails(item) {
      api.openWin({
        name: "tightcloseitem02",
        url: "./tightenup-tightcloseitem02.html",
        pageParam: {
          item: item,
        },
        reload: true,
      });
    },
    //保存
    submitCheck() {
      var body = {};
      body = this.item;
      if (this.item.Creator == "" || this.item.Creator == null) {
        body.Creator = this.user.userName;
      }
      body.Modifytor = this.user.userName;
      body.ModifyDatetime = this.getNowTime();
      this.SaveCheckEntity(body);
    },
    async SaveCheckEntity(body) {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "请稍等...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/AddStrictCloseRequest/SaveEntity",

          {
            body: body,
          }
        );
        if (res.Message != null) {
          //message不为空,有报错信息，打卡失败 暂时这样判断
          Toast.clear();
          Toast.fail("保存失败,请核对信息！");
        } else {
          //打卡成功
          Toast.clear();
          Toast.success("保存成功！");
          setTimeout(function () {
            _this.$ac.closeWin();
          }, 2000);
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    }
  },
};
</script>
<style>
body {
  background-color: White;
}

.pic {
  width: 100%;
  text-align: center;
}

.formstyle {
  margin-top: 8px;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.clickbtn {
  width: 1;
  margin: 5px 10px;
  line-height: 45px;
  border: 1px #ccc dashed;
  text-align: center;
}

.buttonColor {
  background-color: #ff9933;
  border-color: #ff9933;
}

.buttonColor2 {
  background-color: #1076c0;
  border-color: #1076c0;
}

.message {
  font-size: 15px;
  margin-top: 5px;
  margin-left: -10px;
  font-weight: bold;
}

.divStyle {
  border: 1px solid #dcdcdc;
  border-top-width: 3px;
  border-left-width: 3px;
  margin-left: 5px;
  margin-right: 4px;
  margin-top: 4px;
}

.pagination {
  position: fixed;
  bottom: 15px;
  width: 300px;
  margin-left: 10%;
  color: rgb(0, 0, 255);
  text-align: center;
}

.divMedia {
  margin-top: 0px;
  height: 230px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.divMedia2 {
  margin-top: 0px;
  height: 160px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.button {
  position: fixed;
  left: 5px;
  right: 5px;
  bottom: 24px;
  width: 100%;
  height: 30px;
  font-size: 12px;
}

.divMessage {
  margin-top: 0px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.Field {
  font-weight: bold;
  font-size: 15px;
  color: #27208a;
  height: 45px;
  border-bottom: 2px solid rgba(82, 76, 76, 0.39);
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 5rem;
  bottom: 0rem;
  overflow: scroll;
  right: 0;
  width: 100%;
  z-index: 1;
}
</style>
